# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: David Birks <david@birks.dev>
# Contributor: Mike Williamson <mike at korora dot ca>

pkgname=eksctl
pkgver=0.150.0
pkgrel=1
pkgdesc='Command line tool for creating clusters on Amazon EKS'
url='https://github.com/weaveworks/eksctl'
arch=('loong64' 'x86_64')
license=('Apache')
depends=('kubectl' 'glibc')
makedepends=('go')
source=("${url}/archive/${pkgver}/${pkgname}-${pkgver}.tar.gz")
sha256sums=('2169db79b21295f471b31701e2e2978701ff8e6982392f74d9d1e7291f3db669')
b2sums=('ada0c90324401eace645d5375d5ea87a176eca3cc640f5bdc32eeffac95e4dae4fe77dfe154acb19f534cf857774e9f0646de3b3b262818ad5f3375edaaf5118')

build() {
  cd ${pkgname}-${pkgver}
  export CGO_CFLAGS="${CFLAGS}"
  export CGO_CXXFLAGS="${CXXFLAGS}"
  export CGO_CPPFLAGS="${CPPFLAGS}"
  export CGO_LDFLAGS="${LDFLAGS}"
  export GOFLAGS="-buildmode=pie -ldflags=-linkmode=external -trimpath -mod=readonly -modcacherw"
  go build -v \
    -ldflags "-linkmode=external -extldflags '${LDFLAGS}' -X github.com/weaveworks/eksctl/pkg/version.gitTag=${pkgver}" \
    ./cmd/eksctl
}

package() {
  cd ${pkgname}-${pkgver}
  install -Dm 755 ${pkgname} -t "$pkgdir/usr/bin"

  install -Dm 644 README.md -t "${pkgdir}/usr/share/doc/${pkgname}"

  # completions
  "${pkgdir}/usr/bin/${pkgname}" completion bash | install -Dm 644 /dev/stdin "${pkgdir}/usr/share/bash-completion/completions/${pkgname}"
  "${pkgdir}/usr/bin/${pkgname}" completion zsh | install -Dm 644 /dev/stdin "${pkgdir}/usr/share/zsh/site-functions/_${pkgname}"
  "${pkgdir}/usr/bin/${pkgname}" completion fish | install -Dm 644 /dev/stdin "${pkgdir}/usr/share/fish/completions/${pkgname}.fish"
}

# vim: ts=2 sw=2 et:
